import { applyDecorators, SetMetadata, UseGuards } from '@nestjs/common';
import { PERMISSIONS_METADATA } from 'nest-authz';
import { ApiBearerAuth } from '@nestjs/swagger';
// @app/common
import { AuthZGuard } from '@app/common';

export const AuthPermissions = (...permissions: string[]) => {
  // 装饰器 + 守卫
  return applyDecorators(
    ApiBearerAuth(),
    UseGuards(AuthZGuard),
    SetMetadata(PERMISSIONS_METADATA, permissions),
  );
};
